<template>
    <div>
        <div class="breadcrumb-box">
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item :to="{ path: '/demandList' }">需求上架</el-breadcrumb-item>
                <el-breadcrumb-item>需求上架详情</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="line">
            <img :src="$global.Image.icon_goods_line" />
        </div>
        <div class="container">
            <div class="line-ti">
                <div>需求上架详情</div>
            </div>
            <div class="write-info-tit">{{info.name}}</div>
            <el-form label-width="120px">
                <el-form-item label="提交时间：">
                    <el-input :value="info.create_time" readonly placeholder="请输入提交时间："></el-input>
                </el-form-item>
                <el-form-item label="联系人：">
                    <el-input :value="info.contacts" readonly placeholder="请输入联系人"></el-input>
                </el-form-item>
                <el-form-item label="联系电话：">
                    <el-input :value="info.mobile" readonly placeholder="请输入联系电话"></el-input>
                </el-form-item>
                <el-form-item label="商品名称：">
                    <el-input :value="info.name" readonly placeholder="请输入商品名称"></el-input>
                </el-form-item>
                <el-form-item label="品牌名称：">
                    <el-input :value="info.brand" readonly placeholder="请输入品牌名称"></el-input>
                </el-form-item>
                <el-form-item label="型号：">
                    <el-input type="textarea" :value="info.content" readonly placeholder="请输入型号"></el-input>
                </el-form-item>
                <el-form-item label="参数：">
                    <el-input type="textarea" :value="info.content1" readonly placeholder="请输入商品参数"></el-input>
                </el-form-item>
                <el-form-item label="附件：">
                    <div class="file">
                        <div class="td-f1">
                            <div class="el-form-item__content upload-img">
                                <ul class="el-upload-list el-upload-list--picture" v-if="info.files&&info.files.length">
                                    <template v-for="(item,index) in info.files">
                                        <li :tabindex="index" class="el-upload-list__item el-upload-list__item1" :key="index" v-if="imgExt.indexOf(item.ext) !== -1">
                                            <img :src="item.src" class="el-upload-list__item-thumbnail">
                                            <a class="el-upload-list__item-name"><i class="el-icon-document"></i>{{item.name}}</a>
                                            <i class="el-icon-download" @click="download(item.src, item.name)"></i>
                                        </li>
                                        <li :tabindex="index" class="el-upload-list__item el-upload-list__item1" :key="index" v-else>
                                            <i class="el-icon-document el-upload-list__item-thumbnail" style="font-size:66px;"></i>
                                            <a class="el-upload-list__item-name"><i class="el-icon-document"></i>{{item.name}}</a>
                                            <i class="el-icon-download" @click="download(item.src, item.name)"></i>
                                        </li>
                                    </template>
                                </ul>
                                <div v-else>无附件</div>
                            </div>
                        </div>
                    </div>
                </el-form-item>
                <el-form-item>
                    <el-button type="success" @click="$router.go(-1)">返回</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>

<script>
import { articleDetail } from '@api/user';
import { downloadUrlFile } from '@/utils/download';

export default {
    data() {
        return {
            id: this.$route.params.id,
            imgExt: ['.jpg', '.jpeg', '.gif', '.png', 'jpg', 'jpeg', 'gif', 'png'],
            info: {},
            loading: false,
        };
    },
    methods:{
        getDetail(){
            let data = {
                id: this.id
            }
            if (this.loading) return;
            this.loading = true
            articleDetail(data).then(res => {
                this.info = res.data;
                this.loading = false
            });
        },
        download (url, filename) {
            downloadUrlFile(url, filename)
        }
    },
    mounted(){
        this.getDetail()
    }
};
</script>
<style scoped  lang="scss">
@import '../../assets/css/common/create.scss';
</style>